#include<cstdio>
#include<algorithm>
using namespace std;
struct cn{
	int a,b;
}pl1[100005],pl2[100005];
int n,m1,m2;
int ans[2][100005],f[3];
inline int MaXfun(int x,int y){return x>y?x:y;}
inline bool cmp1(cn x,cn y){return x.a==y.a?x.b<y.b:x.a<y.a;}
inline void toFind(int len,cn x[],int g,int t){
	int q[100005]={0};
	int num=0,cnt=0;
	f[t]=1;
	//printf("%d %d %d\n",len,g,t);
	for(int i=0;i<len;++i){
		int now=x[i].a;
		for(int j=0;j<cnt&&num;++j)
			if(q[j]<now){
				num--;
				q[j]=0x3f3f3f3f;
			}
		if(num<g){
			q[cnt]=x[i].b;
			num++;cnt++;
			if(num==len){
				ans[t][g]=g;
				return;
			}
			ans[t][g]=MaXfun(cnt,ans[t][g]);
		}
		else
			f[t]=0;
	}
}
int main(){
	freopen("airport.in","r",stdin);
	freopen("airport.out","w",stdout);
	scanf("%d%d%d",&n,&m1,&m2);
	for(int i=0;i<m1;++i)
		scanf("%d%d",&pl1[i].a,&pl1[i].b);
	for(int i=0;i<m2;++i)
		scanf("%d%d",&pl2[i].a,&pl2[i].b);
	sort(pl1,pl1+m1,cmp1);
	sort(pl2,pl2+m2,cmp1);
	for(int i=1;i<=n;++i){
		if(!f[1])
			toFind(m1,pl1,i,0);
		else
			ans[0][i]=ans[0][i-1];
		if(!f[2])
			toFind(m2,pl2,i,1);
		else
			ans[1][i]=ans[1][i-1];
	}
	int ans0=0;
	for(int i=0;i<=n;++i)
		ans0=MaXfun(ans0,ans[0][i]+ans[1][n-i]);
	printf("%d\n",ans0);
	return 0;
}
